void main(){

/**
forEach
map
where
any
every
 */

var str=["西瓜","芒果","香蕉","芒果","西瓜"];

//用for循环去遍历
for(var i=0;i<str.length;i++){

print(str[i]);

}

print("---------------");

//遍历2
for(var item in str){

print(item);

}

print("---------------");

//用forEach()遍历
str.forEach((value){

print("$value");

});

//map主要用于修改集合里面的数据
List myList=[1,2,3];

var newList=myList.map((value){

return value*2;

});

print(newList.toList());//[2, 4, 6]

  
//where遍历满足条件的数组
  List myList1=[1,2,3,4,5,6,7,8];
var newList1=myList1.where((value){

return value>3;

});

print(newList1.toList());//[4, 5, 6, 7, 8]

//any和every表示判断List里面有没有满足条件的数据 返回true/false
  
  List myList2=[1,2,3,4,5,6,7,8];

var f=myList2.any((value){//只要集合里面有满足条件的就返回true

return value>5;

});

print(f);//true


var f1=myList2.every((value){//每一个都满足条件返回true 否则返回false

return value>5;

});

print(f1);//false


//循环set

var s=new Set();

s.addAll([1,2,3445]);

s.forEach((value){

return print("$value");

});


//循环map

var person={

"name":"张三",
"age":20,
"sex":"男"

};

person.forEach((key,value){

return print("$key-----$value");

});

}